import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

public class ListTest {
    public static void main(String[] args) throws Exception{
        //利用反射机制，破解泛型的限制
        List<String> list = new ArrayList<>();
        list.add("哈哈哈");
        Class<? extends List> aClass = list.getClass();
        Method add = aClass.getMethod("add", Object.class);
        add.invoke(list,true);
        System.out.println(list);
    }
}
